package com.admin.education.models;

import com.admin.education.models.Enum.HttpMethod;
import com.admin.education.repositories.Identifiable;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;

@Data
@Entity
@Table(name="scopes")
@EntityListeners(AuditingEntityListener.class)
public class Scopes implements Serializable,Identifiable {
    @Column(name = "id")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;
    @Column(name="scope_name")
    @Length(max = 128)
    @NotNull
    private String scopeName;
    @Column(name="path")
    @Length(max = 128)
    @NotNull
    private String path;
    @Column(name="method")
    @NotNull
    private HttpMethod method;
    @Column(name="description")
    @Length(max=256)
    private String description;
    @ManyToMany
    @JSONField(serialize=false)
    private List<Role> roles;

}